import { SETCITYNAME, SETPOSTCODES, SETCITYLIST, SETCITYID } from '../mutation-type'
import axios from '@/utils/axios'
const module = {
  namespaced: true, // 命名空间
  state: {
    cities: [],
    cityName: '北京',
    Postcodes: '110100',
    cityId: '101010100'
  },
  actions: {
    getCitiesAction (context, payload) {
      axios.get('/vant/cities').then(res => {
        context.commit('SETCITYLIST', res.data.result)
      })
    }
  },
  mutations: {
    [SETCITYLIST] (state, payload) {
      state.cities = payload
    },
    [SETCITYNAME] (state, payload) {
      state.cityName = payload
    },
    [SETPOSTCODES] (state, payload) {
      state.Postcodes = payload
    },
    [SETCITYID] (state, payload) {
      state.cityId = payload
    }
  }
}

export default module
